#!/user/bin/env python3
# -*- coding: utf-8 -*-

# import time

"""
输入：用户名和密码
输出：验证信息
"""


def login(username, password):
    if username == 'admin' and password == '123456':
        print("欢迎用户%s，恭喜您成功登陆！" % username)
        return True
    elif username != 'admin':
        print("您输入的用户名有错误,请重新输入!")
        return False
    else:
        print("您输入的密码有错误，请重新输入!")
        return False


# count = 0  # 记录错误次数
# while count < 5:
#     ret = login(input("请输入用户名:"), input("请输入登录密码:"))
#     if ret:
#         break
#     else:
#         count += 1
#
#     if count == 5:
#         time.sleep(30)


"""
输入:英制单位英寸
输出:公制单位厘米
1英寸 = 2.54厘米
"""


def in_transfer_cm():
    value = float(input("请输入长度:"))
    unit = input("请输入单位:")
    if unit == 'in' or unit == "英寸":
        print("%.2f英寸 = %.2f厘米" % (value, value * 2.54))
    elif unit == 'cm' or unit == "厘米":
        print("%.2f厘米 = %.2f英寸" % (value, value / 2.54))
    else:
        print("无效的单位")


# in_transfer_cm()

"""
输入:三条边的边长,判断三条边能否构成一个三角形
输出:输出三角形的周长和面积
"""


def helen_formula():
    a = float(input('a = '))
    b = float(input('b = '))
    c = float(input('c = '))
    if a + b > c and a + c > b and b + c > a:
        print("周长为%.2f" % (a + b + c))
        p = (a + b + c) / 2
        area = (p * (p-a) * (p-b) * (p-c)) ** 0.5
        print("面积为%.2f" % area)
    else:
        print("这三条边不能构成三角形")


# helen_formula()
